import fs from 'fs'
import path from 'path'

export default ()=>{
    return{
        configureServer(server){
            server.middlewares.use((request,response,next)=>{//next方法会将请求传递给下一个中间件
                if(request.url==='/api/users'){
                    const folderList=fs.statSync(path.resolve(process.cwd(),'./mock'))
                   
                    if(folderList.isDirectory()){
                       const absMockPath=path.resolve(process.cwd(),'./mock/index.js')
                       console.log(absMockPath)
                        const mockData=import(absMockPath)
                        console.log('111',mockData)
                    }
                }else{
                    next()
                }
            })
        }
    } 
}